﻿function addTab(tit, link) {
    if ($('#tt').tabs('exists', tit)) {
        $('#tt').tabs('select', tit);
        //$.messager.alert('提示消息', '窗口已经打开。', 'info');
        
    } else {        
        $('#tt').tabs('add', {
            title: tit,            
            content: '<iframe scrolling="yes" frameborder="0"  src="' + link + '" style="width:100%;height:98%;"></iframe>',
            fit: true,
            closable: true
        });        
    }
}

//json时间转为 标准时间格式
function JSONDateToJSDate(JSONDateString) {
    if (JSONDateString) {
        var date = new Date(parseInt(JSONDateString.replace("/Date(", "").replace(")/", ""), 10));
        var hh = date.getHours();
        var mm = date.getMinutes();
        var ss = date.getSeconds();
        var yy = date.getFullYear();
        var MM = date.getMonth() + 1;
        var dd = date.getDate();
        return yy + "-" + MM + "-" + dd + " " + hh + ":" + mm + ":" + ss;
    }
}

//JS 中国标准时间 转换函数 
var format = function (time, format) {
    var t = new Date(time);
    var tf = function (i) { return (i < 10 ? '0' : '') + i };
    return format.replace(/yyyy|MM|dd|HH|mm|ss/g, function (a) {
        switch (a) {
            case 'yyyy':
                return tf(t.getFullYear());
                break;
            case 'MM':
                return tf(t.getMonth() + 1);
                break;
            case 'mm':
                return tf(t.getMinutes());
                break;
            case 'dd':
                return tf(t.getDate());
                break;
            case 'HH':
                return tf(t.getHours());
                break;
            case 'ss':
                return tf(t.getSeconds());
                break;
        }
    })
}
//获取当天0点时间
function getNowZeroDate() {
    var beginTime = new Date();
    beginTime.setHours(0);
    beginTime.setMinutes(0);
    beginTime.setSeconds(0);
    beginTime.setMilliseconds(0);
    var beginTime1 = format(beginTime, 'yyyy-MM-dd 00:00:00');
    return beginTime1;
}
//获取当前时间
function getNowFormatDate() {
    var myDate = new Date();
    var y = myDate.getFullYear();
    var m = myDate.getMonth() + 1;
    var d = myDate.getDate();
    var hour = myDate.getHours();
    var minute = myDate.getMinutes();
    var second = myDate.getSeconds();
    if (m >= 1 && m <= 9) {
        m = "0" + m;
    }
    if (d >= 0 && d <= 9) {
        d = "0" + d;
    }
    var endTime = y + '-' + m + '-' + d + ' ' + hour + ':' + minute + ':' + second;
    return endTime;
}

//管理员账号
function bindAdminCombogrid(ctl) {
    $('#' + ctl).combogrid({
        panelWidth: 450,
        idField: 'AdminId',
        textField: 'AdminUserName',
        url: '/Manager/MerList',
        fitColumns: true,
        striped: true,
        editable: true,
        pagination: true,//是否分页  
        rownumbers: true,//序号  
        collapsible: false,//是否可折叠的  
        fit: true,//自动大小  
        pageSize: 10,//每页显示的记录条数，默认为10  
        pageList: [10],//可以设置每页记录条数的列表  
        method: 'post',
        columns: [[
            { field: 'AdminId', title: 'Id', width: 40 },
            { field: 'AdminUserName', title: '账号', width: 80 },
            { field: 'TrueName', title: '姓名', width: 80 }
        ]],
        keyHandler: {
            query: function (q) {
                $('#' + ctl).combogrid("grid").datagrid("reload", { 'UserName': q });
            }
        }
    });
}


//项目
function bindReUserCombogrid(ctl) {
    $('#' + ctl).combogrid({
        panelWidth: 450,
        idField: 'UserID',
        textField: 'UserTitle',
        url: '/ReUser/ReUserList',
        fitColumns: true,
        striped: true,
        editable: true,
        pagination: true,//是否分页  
        rownumbers: true,//序号  
        collapsible: false,//是否可折叠的  
        fit: true,//自动大小  
        pageSize: 10,//每页显示的记录条数，默认为10   
        pageList: [10],//可以设置每页记录条数的列表  
        method: 'post',
        columns: [[
            { field: 'UserID', title: 'Id', width: 20 },
            { field: 'UserTitle', title: '项目名称', width: 100 }
        ]],
        keyHandler: {
            query: function (q) {
                $('#' + ctl).combogrid("grid").datagrid("reload", { 'UserName': q });
            }
        }
    });
}
    function bindReUserCombobox(objId,selValue) {
        $('#' + objId).combobox({
            url: '/ReUser/JsonList',
            editable: false,
            valueField: 'UserID',
            textField: 'UserTitle'
        });

        //默认值
        if (selValue) {
            $("#" + objId).combobox("setValue", value);
        }
    }


